using System;
namespace GameHelper.Saving
{

    [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
    public class SaveAttribute : Attribute
    {
        public Type valueType { get; set; }

        /// <summary>
        ///   是否缓存存档值
        /// </summary>
        public bool useCache { get; set; } = true;

        /// <summary>
        /// 前缀模式, 开启后，键值作为存档key的前缀，完整的键值通过前缀+suffix的形式拼接
        /// </summary>
        public Type suffixType { get; set; }

        public string comment
        {
            get {
                return _comment;
            }
            set {
#if UNITY_EDITOR
                _comment = value;
#endif
            }
        }

        private string _comment;

        public SaveAttribute(Type type)
        {
            this.valueType = type;
        }
    }

    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum, AllowMultiple = false)]
    public class CodeGenAttribute : Attribute
    {
        /// <summary>
        ///   脚本路径
        /// </summary>
        public string scriptName { get; set; }

        /// <summary>
        ///   类名称，如过不指定，先解析scriptName，提取文件名作为类名
        /// </summary>
        public string typeName { get; set; }

        /// <summary>
        ///   脚本命名空间
        /// </summary>
        public string typeNamespace { get; set; }

        /// <summary>
        ///   is partial class?
        /// </summary>
        public bool isPartialType { get; set; } = true;

        /// <summary>
        /// 生成的代码添加编译开关，防止存档后端切换时编译报错问题
        /// </summary>
        public string scriptSharpIf { get; set; }

        public bool v2 { get; set; }

        public CodeGenAttribute(string scriptName, string typeName)
        {
            this.scriptName = scriptName;
            this.typeName = typeName;
        }
    }
}
